#!/bin/bash
# 检查磁盘使用率超过 80% 的分区
df -h | grep -E '/dev|%' | awk '{ print $5 " " $1 }' | while read output;
do
    disk=`echo $output | awk '{ print $2 }'`
    usage=`echo $output | awk '{ print $1 }' | sed 's/%//g'`
    if [ $usage -ge 80 ]; then
        echo "警告：磁盘 ${disk} 使用率已达 ${usage}%"
    fi
done